package com.ruoyi.web.controller.wnjk.physical;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.wnjk.domain.po.PhysicalOrder;
import com.ruoyi.system.wnjk.service.IWnjkPhysicalExaminationOrderService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检订单Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/physical/order")
public class PhysicalOrderController extends BaseController
{
    @Autowired
    private IWnjkPhysicalExaminationOrderService wnjkPhysicalExaminationOrderService;

    /**
     * 查询体检订单列表
     */
    @PreAuthorize("@ss.hasPermi('physical:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(PhysicalOrder wnjkPhysicalExaminationOrder)
    {
        startPage();
        List<PhysicalOrder> list = wnjkPhysicalExaminationOrderService.selectWnjkPhysicalExaminationOrderList(wnjkPhysicalExaminationOrder);
        return getDataTable(list);
    }

    /**
     * 导出体检订单列表
     */
    @PreAuthorize("@ss.hasPermi('physical:order:export')")
    @Log(title = "体检订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PhysicalOrder wnjkPhysicalExaminationOrder)
    {
        List<PhysicalOrder> list = wnjkPhysicalExaminationOrderService.selectWnjkPhysicalExaminationOrderList(wnjkPhysicalExaminationOrder);
        ExcelUtil<PhysicalOrder> util = new ExcelUtil<PhysicalOrder>(PhysicalOrder.class);
        util.exportExcel(response, list, "体检订单数据");
    }

    /**
     * 获取体检订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('physical:order:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
    {
        return success(wnjkPhysicalExaminationOrderService.selectWnjkPhysicalExaminationOrderByOrderId(orderId));
    }

    /**
     * 新增体检订单
     */
    @PreAuthorize("@ss.hasPermi('physical:order:add')")
    @Log(title = "体检订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PhysicalOrder wnjkPhysicalExaminationOrder)
    {
        return toAjax(wnjkPhysicalExaminationOrderService.insertWnjkPhysicalExaminationOrder(wnjkPhysicalExaminationOrder));
    }

    /**
     * 修改体检订单
     */
    @PreAuthorize("@ss.hasPermi('physical:order:edit')")
    @Log(title = "体检订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PhysicalOrder wnjkPhysicalExaminationOrder)
    {
        return toAjax(wnjkPhysicalExaminationOrderService.updateWnjkPhysicalExaminationOrder(wnjkPhysicalExaminationOrder));
    }

    /**
     * 删除体检订单
     */
    @PreAuthorize("@ss.hasPermi('physical:order:remove')")
    @Log(title = "体检订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable String[] orderIds)
    {
        return toAjax(wnjkPhysicalExaminationOrderService.deleteWnjkPhysicalExaminationOrderByOrderIds(orderIds));
    }


}